package com.open4cn.simulator.connect.com.handler;

import com.open4cn.simulator.core.connector.serialport.ByteToMessageDecoder;
import com.open4cn.simulator.core.connector.serialport.SerialPortHandlerContext;

import java.nio.charset.StandardCharsets;

/**
 * @author yinxiaopeng
 * @version 1.0.0
 * @company 致景科技
 * @department 飞梭BU/研发
 * @description
 * @Email yinxiaopeng@zj.tech
 * @date 2022-06-12 01:55
 */
public class ByteToStringDecoder extends ByteToMessageDecoder {

    @Override
    protected void decode(SerialPortHandlerContext ctx, Object msg) {
        String str = new String((byte[]) msg, StandardCharsets.US_ASCII);
        ctx.fireRead(str);
    }
}
